import util.GuiImg;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class Atm extends JFrame implements ActionListener {
    CardLayout cardLayout=new CardLayout();
    private Image atmImg=GuiImg.getImage("/imgs/background.jpg");
    private ArrayList<User> userArray=new ArrayList();
    private Check check=new Check(this);
    private Login login=new Login(this);
    private Menu menu=new Menu(this);
    private Deposit deposit=new Deposit(this);
    private Get get=new Get(this);
    private Alter alter=new Alter(this);
    private Transfer transfer=new Transfer(this);
    private int index;

    public Atm(){
        this.setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(atmImg,0,0,800,600,this);
            }
        });
        this.setLayout(cardLayout);
        //登录
        this.add("登录",login);
        //菜单
        this.add("菜单",menu);
        //存款
        this.add("存款",deposit);
        //取款
        this.add("取款",get);
        //查询
        this.add("查询",check);
        //改密
        this.add("改密",alter);
        //转账
        this.add("转账",transfer);

        //界面初始化
        this.setSize(800,600);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
    @Override
    public void actionPerformed(ActionEvent e) {

    }

    public static void main(String[] args) {
        new Atm().init();
    }
    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }
    public void init(){
        userArray.add(new User("qqqqqq","111111",500));
        userArray.add(new User("aaaaaa","222222",1500));
        userArray.add(new User("zzzzzz","333333",500));
        userArray.add(new User("xxxxxx","444444",500));
        userArray.add(new User("ssssss","555555",500));
    }

    public ArrayList<User> getUserArray() {
        return userArray;
    }

    public void setUserArray(ArrayList<User> userArray) {
        this.userArray = userArray;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Check getCheck() {
        return check;
    }

    public void setCheck(Check check) {
        this.check = check;
    }

    public Deposit getDeposit() {
        return deposit;
    }

    public void setDeposit(Deposit deposit) {
        this.deposit = deposit;
    }
}
